﻿using System;
using System.Collections.Generic;
using System.Linq;
using MiDu.Common;

namespace Competition.Infrastructure
{
    public class SysHelper
    {
        /// <summary>
        /// 随机产生文件名
        /// </summary>
        /// <returns></returns>
        public static string RandomFileName()
        {
            Random ran = new Random();

            return (DateTimeHelper.ConvertDateTimeInt(DateTime.Now) + ran.Str(4, true)).ToLower();
        }
        /// <summary>
        /// 获取枚举
        /// </summary>
        /// <returns></returns>
        public static List<KeyValuePair<int, string>> GetEnumDictionary(Type enumType)
        {
            var values = Enum.GetNames(enumType);
            List<KeyValuePair<int, string>> enumDictionary = new List<KeyValuePair<int, string>>();

            foreach (var value in values)
            {
                enumDictionary.Add(new KeyValuePair<int, string>((int)Enum.Parse(enumType, value), value));
            }

            return enumDictionary;

        }
    }
}